from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from cemberus.html_meta.models import HtmlMeta, DateMeta


class Category(HtmlMeta, DateMeta, models.Model):
    # Check this!
    user = models.ForeignKey(User, verbose_name = _('Benutzername'))
    
    name = models.CharField(verbose_name = _('Name'), max_length = 100)
    slug = models.SlugField(verbose_name = _('URL'), max_length = 100, unique = True)
    description = models.TextField(verbose_name = _('Beschreibung'))
    
    # TODO: should we sort categories hierachicly, e.g. Category level 1 is Music
    # and level 2 are Jazz and Rock. Or is a flat structure better?
    
    def __unicode__(self):
        return self.name
        
    def get_absolute_url(self):
        return ('category_detail', (), {'slug': self.slug})
    get_absolute_url = models.permalink(get_absolute_url)
        
    class Meta:
        verbose_name = _(u'Kategorie')
        verbose_name_plural = _(u'Kategorien')
    
